package com.bawei.model_sevent.Activity.Activity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.bawei.model_sevent.Activity.Adapter.FragrmentAdapter;
import com.bawei.model_sevent.Activity.Fragemnt.BlankFragment_class;
import com.bawei.model_sevent.Activity.Fragemnt.BlankFragment_main;
import com.bawei.model_sevent.Activity.Fragemnt.BlankFragment_messages;
import com.bawei.model_sevent.Activity.Fragemnt.BlankFragment_myself;
import com.bawei.model_sevent.Activity.Fragemnt.BlankFragment_shoppCar;
import com.bawei.model_sevent.R;

import java.util.ArrayList;

@Route(path = "/app/show_main")
public class MainActivity_main extends AppCompatActivity {

    private TextView showOne;
    private TextView showTwo;
    private Button showLog;
    private  ViewPager vg;
    private BottomNavigationBar bot;
    
    //Kotlin用@JVMfeild
    //Java用这个
//    @Autowired(name = "show_one")
//    String one;
//    @Autowired(name="show_two")
//    String two;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_main);
        ARouter.getInstance().inject(this);

//        SPUtil goods = new SPUtil(MainActivity_main.this, "goods");
//        goods.clear();
//        goods.putString("key1", "values1");
//        goods.putInt("key2", 123);
//        goods.getString("key1", "");
//        goods.getInt("key2", 0);
        initView();
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new BlankFragment_main());
        fragments.add(new BlankFragment_class());
        fragments.add(new BlankFragment_shoppCar());
        fragments.add(new BlankFragment_messages());
        fragments.add(new BlankFragment_myself());
        FragrmentAdapter fragrmentAdapter = new FragrmentAdapter(getSupportFragmentManager(), fragments);
        vg.setAdapter(fragrmentAdapter);
        bot
                .addItem(new BottomNavigationItem(R.drawable.main,"主页"))
                .addItem(new BottomNavigationItem(R.drawable.main,"分类"))
                .addItem(new BottomNavigationItem(R.drawable.myslef,"购物车"))
                .addItem(new BottomNavigationItem(R.drawable.messages,"消息"))
                .addItem(new BottomNavigationItem(R.drawable.myslef,"我的"));
        bot.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
            @Override
            public void onTabSelected(int position) {
                vg.setCurrentItem(position);
            }

            @Override
            public void onTabUnselected(int position) {
                
            }

            @Override
            public void onTabReselected(int position) {
                
            }
        });
        bot.setMode(BottomNavigationBar.MODE_FIXED);
        bot.initialise();
    }

    private void initView() {
        vg = findViewById(R.id.vg);
        bot = findViewById(R.id.bot);
    }
}

   